package com.cantierinformatici.mygym.data.sqlite;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DbHelper extends SQLiteOpenHelper {
	
	public DbHelper(Context context) {
		super(context, Contract.DB_NAME, null, Contract.DB_VERSION);
	}
	
	@Override
	public void onCreate(SQLiteDatabase db){
		db.execSQL(Contract.SQL_CREATE_ESERCIZIO_ENTRIES);
		db.execSQL(Contract.SQL_CREATE_MUSCOLO_ENTRIES);
		db.execSQL(Contract.SQL_CREATE_ATTREZZO_ENTRIES);
		db.execSQL(Contract.SQL_CREATE_ATTIVITA_ENTRIES);
		db.execSQL(Contract.SQL_CREATE_SERIE_ENTRIES);
		db.execSQL(Contract.SQL_CREATE_PESO_ENTRIES);
	}
	
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL(Contract.SQL_DELETE_ESERCIZIO_ENTRIES);
		db.execSQL(Contract.SQL_DELETE_MUSCOLO_ENTRIES);
		db.execSQL(Contract.SQL_DELETE_ATTREZZO_ENTRIES);
		db.execSQL(Contract.SQL_DELETE_ATTIVITA_ENTRIES);
		db.execSQL(Contract.SQL_DELETE_SERIE_ENTRIES);
		db.execSQL(Contract.SQL_DELETE_PESO_ENTRIES);
		onCreate(db);			
	}
}
